<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件分片上传</title>
</head>

<body>
    <h1>文件分片上传</h1>
    <input type="file" id="fileInput" />
    <button id="uploadButton">上传</button>

    <!-- <script defer type="module" src="./spark-md5.js"></script> -->
    <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.2/spark-md5.min.js"></script> -->
    <script type="module" src="./createChunk.js"></script>
    <script type="module" src="./cutFile.js"></script>
    <script type="module">
        import { cutFile } from './cutFile.js'
        document.getElementById('fileInput').addEventListener('change', async () => {
            const file = document.getElementById('fileInput').files[0];
            console.log('拿到文件:', file)
            console.time('上传文件计时')
            try {
                const res = await cutFile(file)
                console.log('文件切割完成', res)
                console.timeEnd('上传文件计时')
            } catch (error) {
                console.log('文件切割失败', error)
            }
        });
    </script>
</body>

</html>